<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/shadow-dom.js"></script>
</head>
<body>
<p>This tests navigation from non keyboard-focusable shadow host to its shadow. crbug.com/446584</p>
<pre id="console"></pre>
<script>

function prepareDOMTree(parent)
{
    parent.appendChild(
        createDOM('input', {'id': 'input-in-document-before'}));
    parent.appendChild(
        createDOM('div', {'id': 'host-div', 'tabindex': '-1'},
                  createShadowRoot(
                      createDOM('input', {'id': 'input-in-shadow'}))));
    parent.appendChild(
        createDOM('input', {'id': 'input-in-document-after'}));
    parent.offsetTop;
}

function test() {
    if (!window.eventSender) {
        testFailed('');
        return;
    }

    prepareDOMTree(document.body);

    shouldNavigateFocus('host-div', 'host-div/input-in-shadow', 'forward');
    shouldNavigateFocus('host-div', 'input-in-document-before', 'backward');

    debug('Test finished.');
}

test();
</script>
</body>
</html>
